package com.atguigu.web.handler;

import com.atguigu.web.pojo.User;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice //这个类集中处理所有的错误
public class GlobalExceptionHandler {

    @ResponseBody
    @ExceptionHandler(Exception.class)
    public ResponseEntity errorController(Exception e) {
        ResponseEntity res =new ResponseEntity(new User(1,"jss",14,"address"), HttpStatus.INTERNAL_SERVER_ERROR);
        return res;
    }

}
